package main

import (
	"bufio"
	"os"
	"fmt"
)

func main() {
	file, err := os.OpenFile("./test.txt", os.O_CREATE|os.O_RDWR|os.O_TRUNC , 0666)
	defer file.Close()
	if err != nil {
		fmt.Println("open file failed, err:", err)
		return
	}

	writer := bufio.NewWriter(file)
	for i := 0; i < 10; i++ {
		writer.WriteString("第"+fmt.Sprintf("%d", i+1)+"行\n")
	}
	writer.Flush()
}